/*-------------------------------*
 |  VisualK-OS Flood Bank Array  |
 |  Author: Kevin Slaughter      |
 | Version: 3.3                  |
 *-------------------------------*/
 
/* Revision History
    v3.3: Initial standardization, after many untracked changes as development progressed.
*/

#include "CmdConstants.h"   // CMD constants and typedef/obj definitions
#include "LightManager.h"   // Lighting subsystem wrapper
#include "SerialManager.h"  // Serial I/O
#include <ShiftPWM.h>       // Driver for 74HC595 registers



/* #############
   ## Objects ##
   ############# */
LightManager* LIGHTMAN;
SerialManager* SERIALMAN;


// [ARDUINO] This is executed on boot.
void setup() {
  LIGHTMAN = new LightManager(8,2,75);   // Instantiate light management subsystem (8 RGBs, 2 white floods, pwm freq = 75)
  SERIALMAN = new SerialManager();       // Instantiate serial COMMS management subsystem
  SERIALMAN->setLM(LIGHTMAN);            // Give COMMS manager access to lighting subsystem
  
  // Begin!
  SERIALMAN->init();  // Establish and assert serial connection to host
}


// [ARDUINO] Main loop
void loop() {
  SERIALMAN->assert();  // *** Serial tasks
  
  /* Lighting automation tasks in-progress
     run regardless of serial connection. */
  LIGHTMAN->update();
  
  delay(5);          // Rest
}


// [ARDUINO] Serial Event. Redirect to be handled within the serial manager class.
void serialEvent() {SERIALMAN->handOff();}
